<?php

	defined('_JEXEC') or die('Restricted access');
	
?>
<script src="<?php echo  JURI::root( true ); ?>/media/system/js/jquery-1.4.2.min.js" type="text/javascript"></script>
<script type="text/javascript"> 
     jQuery.noConflict(); 
 </script>
<script type="text/javascript">
	function additional_img(){
		jQuery('<input type=file name=\'additional_image[]\' /><br/> ').insertAfter('#addit_img br:last');
	}
	
	function additional_field(num){
		jQuery('<input class="text_area" type="text" name="value_'+num+'[]"  size="50" maxlength="100" /> Количество: <input class="text_area" type="text" name="sklad_'+num+'[]"  size="6" maxlength="10" /><br/>').insertAfter('#field_'+ num +' br:last');
	}
</script>
<form action="" method="post" name="adminForm" id="adminForm" enctype='multipart/form-data'>
<div style="width:100%;float:left;">
<fieldset class="adminform">
    
    <table class="admintable" width="100%">
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Артикул товара' ); ?>
                </label>
            </td>
			<td valign="top">
                <input class="text_area" type="text" name="articul"  size="50" maxlength="100" value="<?php echo isset($this->item->articul)?$this->item->articul:'';?>" />
            </td>
        </tr>
        <tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Название товара' ); ?>
                </label>
            </td>
			<td valign="top">
                <input class="text_area" type="text" name="name"  size="50" maxlength="100" value="<?php echo isset($this->item->name)?htmlspecialchars($this->item->name):'';?>" />
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Тег title товара' ); ?>
                </label>
            </td>
			<td valign="top">
                <input class="text_area" type="text" name="metatitle"  size="50" maxlength="" value="<?php echo isset($this->item->metatitle)?$this->item->metatitle:'';?>" />
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Категория' ); ?>
                </label>
            </td>
			<td valign="top">
				<select name="cat_id" >
					<?php foreach($this->categories as $cat):?>
					<option value="<?php echo $cat->id;?>" <?php if(isset($this->item)) echo ($this->item->cat_id == $cat->id)?'SELECTED':'';?>><?php echo $cat->name;?></option>
					<?php endforeach;?>
				</select>			
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Дублировать в категорию(выберите категорию отличную от основной)' ); ?>
                </label>
            </td>
			<td valign="top">
				<select name="dublicated_cat" >
					<option value=""></option>
					<?php foreach($this->categories as $cat):?>
					<option value="<?php echo $cat->id;?>" <?php if(isset($this->item)) echo ($this->item->dublicated_cat == $cat->id)?'SELECTED':'';?>><?php echo $cat->name;?></option>
					<?php endforeach;?>
				</select>			
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Фотография' ); ?>
                </label>
            </td>
			<td valign="top">
			<?php if($this->item->main_img != '') echo '<img src="'.(JURI::root( true )).'/components/com_shop/images/small/'.$this->item->main_img.'" /><br/>'?>
				<input type=file name=main_img />                
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Дополнительные фотографии' ); ?>
                </label>
            </td>
			<td valign="top">
			<?php if($this->item->add_img != '') { echo '<table><tr align="center">'; $additional = explode(';',$this->item->add_img); foreach($additional as $k=>$img) echo '<td><img src="'.(JURI::root( true )).'/components/com_shop/images/small/'.$img.'" /><br/><a href="index.php?option=com_shop&task=changeMainImage&id='.$this->item->id.'&img='.$img.'">Сделать основным</a><br/><a href="index.php?option=com_shop&task=deletAdditional&id='.$this->item->id.'&num='.$k.'">Удалить фото</a></td>'; echo '</tr></table>'; }?>
			<div id="addit_img">
				<input type=file name='additional_image[]' /> <input type="button" value=" + " id="insertrow" onclick="additional_img();"><br/>     
			</div>
            </td>
        </tr>
		<?php if($this->item->from_xml > 0):?>
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Розничная цена из xml ' ); ?>
                </label>
            </td>
			<td valign="top">
              <?/*  <input class="text_area" type="text" name="price"  size="20" maxlength="20" value="<?php echo isset($this->item->price)?$this->item->price:'';?>" /> руб.*/?>
			  <?php echo $this->item->xml_price;?> руб.
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Закупочная цена ' ); ?>
                </label>
            </td>
			<td valign="top">
                <?php echo $this->item->whole_price?> руб.
            </td>
        </tr>
		<?php endif;?>
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Цена товара' ); ?>
                </label>
            </td>
			<td valign="top">
                <input class="text_area" type="text" name="price"  size="20" maxlength="20" value="<?php echo isset($this->item->price)?$this->item->price:'';?>" /> руб.
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Старая цена, будет отображаться зачеркнутой, если указана' ); ?>
                </label>
            </td>
			<td valign="top">
                <input class="text_area" type="text" name="old_price"  size="20" maxlength="20" value="<?php echo isset($this->item->old_price)?$this->item->old_price:'';?>" /> руб.
            </td>
        </tr>
		
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Опубликовано' ); ?>
                </label>
            </td>
			<td valign="top">
				<select name="published" size="1">
					<option value="1" <?php if(isset($this->item->published) && $this->item->published ==1) echo 'SELECTED';?> >Да</option>
					<option value="0" <?php if(isset($this->item->published) && $this->item->published ==0) echo 'SELECTED';?>>Нет</option>
				</select>
                
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Материал' ); ?>
                </label>
            </td>
			<td valign="top">
                <input class="text_area" type="text" name="material"  size="50" maxlength="100" value="<?php echo isset($this->item->material)?htmlspecialchars($this->item->material):'';?>" />
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;">
                <label for="name">
                    <?php echo JText::_( 'Производитель' ); ?>
                </label>
            </td>
			<td valign="top">
                <input class="text_area" type="text" name="manufact"  size="50" maxlength="100" value="<?php echo isset($this->item->manufact)?htmlspecialchars($this->item->manufact):'';?>" />
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;" valign="top">
                <label for="name">
                    <?php echo JText::_( 'Обновлять описание' ); ?>
                </label>
            </td>
			<td valign="top">
				<input name="update_description" type="checkbox" value=1 <?php if($this->item->update_description == 1) echo 'checked'?>/>             
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;" valign="top">
                <label for="name">
                    <?php echo JText::_( 'На главной' ); ?>
                </label>
            </td>
			<td valign="top">
				<input name="on_main" type="checkbox" value=1 <?php if($this->item->on_main == 1) echo 'checked'?>/>             
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;" valign="top">
                <label for="name">
                    <?php echo JText::_( 'Описание' ); ?>
                </label>
            </td>
			<td valign="top">
				<?php echo $this->editor->display('description', $this->item->description, "500" , "300", '70', '15'); ?>
                
            </td>
        </tr>
		<tr>
			<td  align="left" class="key" style="text-align:left;" valign="top">
                <label for="name">
                    <?php echo JText::_( 'Дополнительные поля' ); ?>
                </label>
            </td>
			<td valign="top">
				 <table class="admintable" width="100%">
					<?php if(count($this->all_fields)>0) foreach($this->all_fields as $key=>$field):?>
					<tr >
						<td  align="left" class="key" style="text-align:left;" valign="top">
							<label >
								<?php echo JText::_( $field->name ); ?> <input type="button" value=" + " id="insertrow" onclick="additional_field(<?php echo $field->id?>);">
							</label>
						</td>
						<td valign="top" id="field_<?php echo $field->id?>">
							<?php if(count($this->field_values[$key])>0) foreach($this->field_values[$key] as $value):?>
							<input class="text_area" type="text" name="value_<?php echo $field->id?>[]"  size="50" maxlength="100" value="<?php echo $value->value;?>" /> Количество: <input class="text_area" type="text" name="sklad_<?php echo $field->id?>[]"  size="6" maxlength="10" value="<?php echo $value->sklad;?>" /><input type="hidden" name="old_field_id_<?php echo $field->id?>[]" value="<?php echo $value->id?>"/><br/>
							<?php endforeach;
								else 
									echo '<input class="text_area" type="text" name="value_'.$field->id.'[]"  size="50" maxlength="100" /> Количество: <input class="text_area" type="text" name="sklad_'.$field->id.'[]"  size="6" maxlength="10" /><br/>';

							?>
						</td>
					</tr>
					<?php endforeach;?>
				</table>
            </td>
		</tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;" valign="top">
                <label for="name">
                    <?php echo JText::_( 'Дополнительный текст на странице с товаром' ); ?>
                </label>
            </td>
			<td valign="top">
				<?php echo $this->editor->display('additional_text', $this->item->additional_text, "500" , "300", '70', '15'); ?>
                
            </td>
        </tr>
		<tr >
            <td  align="left" class="key" style="text-align:left;" valign="top">
                <label for="name">
                    <?php echo JText::_( 'Ключевые слова' ); ?>
                </label>
            </td>
			<td valign="top">
				<?php foreach($this->keywords as $keyword):?>
					
					<input name="keyword[<?php echo $keyword->id?>]" type="checkbox" value=1 <?php if(isset($this->related_keywords[$keyword->id])) echo 'checked'?>/> <?php echo $keyword->name?><br/>  
					
				<?php endforeach;?>
            </td>
        </tr>
    </table>
</fieldset>

</div>

<input type="hidden" name="option" value="com_shop" />
<input type="hidden" name="pager" value="<?php echo JRequest::getVar('pager');?>" />

<input type="hidden" name="cat" value="<?php echo JRequest::getVar('cat');?>" />

<input type="hidden" name="id" value="<?php echo $this->item->id; ?>" />
<input type="hidden" name="task" value="" />


</form>
